package com.metel.mservice.common.bean;

import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class PropertyBean {
	public static String localConfFileName;
	//public static int imageUtilMaxInstance = 10;
	//public static String imageUtilTmpDir;
	public static String versionJsFileName;
	public static int keyExpireDate;
	public static Set<String> excludeUrls;
	public static Set<String> secureUrls;
	public static Set<String> allowedIPs;
	
	public static boolean zkServiceUse = false;
	public static String zkServiceHosts = "localhost:2185";
	public static int zkServiceSessionTimeout = 10000;
	public static String zkServiceNode = "";
	
	// External Server
	public static String licenseServer;
	public static int 	 internalConnectionTimeout;
	
	/**
	 * MySQL DB's secured username and password
	 */
	public static String securedDBUsername;
	public static String securedDBPassword;
	
	/**
	 * SMS Gateway Server Url
	 */
	public static String smsAuthServerUrl;

	//public static String S3PROXY;
	public static String bucketName;
	public static String accessKey;
	public static String secretKey;
	public static String client_log;
	//public static String supportedFiles;
	public static String fileSignatures;
	public static int bufferSize;

	public static String successActionRedirectUrl;
	public static String openAPIServerUrl;
	public static String openAPIFileServerUrl;
	
	public static int smsValidTime = 3;//mininute
	
	
	// CookieHandler
	public static String cookieEncryptKey;

	/**
	 * ssm connection timeout (second)
	 */
	public static int ssmConnectionTimeout = 5;
	
	/**
	 * ssm <-> messageserver  Encryption  0: On , 1: Off
	 */
	public static int ssmMsgEncryption = 0;
	
	/**
	 * send msg to push server ( 0 : off, 1: on )
	 */
	public static int sppNoti = 0;
	
	/**
	 * thread size to send msg to push server 
	 */
	public static int sppThreadpoolsize = 100;
	
	/**
	 * push close time check by scheduler (Second)
	 */
	public static int pushClosetime = 15;

	/**
	 * polling scheduler interval (Second)
	 */
	public static int pushSchedulerInterval = 5;
	
	/**
	 * polling scheduler thread size
	 */
	public static int pushSchedulerThreadpoolsize = 1000;
	
	/**
	 * queue thread size
	 */
	public static int pushQueueThreadpoolsize = 1000;
	
	public static String gldAddress;
	
	public static String gldCliversion;
	
	public static int gldPort;
	
	public static String gldProtocol;

	public static String fileSvrProtocol = "http://";
	
	public static String buddySvrProtocol = "http://";
	
	public static String fileSvrAddr = "http://";
	
	public static String buddySvrAddr = "http://";
	
	public static String[] file_url_mapping = null;
	
	// DB region / GLD region Mapping
	public static String[] regionJp;
	public static String[] regionSg;
	public static String[] regionEu;
	public static String[] regionCn;
	public static String[] regionKr;
	public static String[] regionDev;
	public static String[] regionStg;
	
	// account server
	public static String apiAccountHost;
	
	public static String serverType = null;
	
	public static int httpSotimeout;
	public static int httpConnectionTimeout;
	
	public static String decryptMode;
	public static String encryptMode;	
	
	//elb info
	public static String elbinfoMsgPriElbAddr;
	public static int elbinfoMsgPriPort;
	public static String elbinfoMsgSecElbAddr;
	public static int elbinfoMsgSecPort;
	
	
	
	public String getLocalConfFileName() {
		return localConfFileName;
	}

	public void setLocalConfFileName(String localConfFileName) {
		PropertyBean.localConfFileName = localConfFileName;
	}

	public boolean getZkServiceUse() {
		return zkServiceUse;
	}

	public void setZkServiceUse(boolean zkServiceUse) {
		PropertyBean.zkServiceUse = zkServiceUse;
	}

	public String getZkServiceHosts() {
		return zkServiceHosts;
	}

	public void setZkServiceHosts(String zkServiceHosts) {
		PropertyBean.zkServiceHosts = zkServiceHosts;
	}
	
	public String getZkServiceNode() {
		return zkServiceNode;
	}

	public void setZkServiceNode(String zkServiceNode) {
		PropertyBean.zkServiceNode = zkServiceNode;
	}

	public int getZkServiceSessionTimeout() {
		return zkServiceSessionTimeout;
	}

	public void setZkServiceSessionTimeout(int zkServiceSessionTimeout) {
		PropertyBean.zkServiceSessionTimeout = zkServiceSessionTimeout;
	}
	
	public String getVersionJsFileName() {
		return versionJsFileName;
	}

	public void setVersionJsFileName(String versionJsFileName) {
		PropertyBean.versionJsFileName = versionJsFileName;
	}

	public int getKeyExpireDate() {
		return keyExpireDate;
	}

	public void setKeyExpireDate(int keyExpireDate) {
		PropertyBean.keyExpireDate = keyExpireDate;
	}

	public void setExcludeUrls(Set<String> excludeUrls) {
		PropertyBean.excludeUrls = excludeUrls;
	}

	public Set<String> getExcludeUrls()
	{
		return PropertyBean.excludeUrls;
	}
	
	public void setSecureUrls(Set<String> secureUrls) {
		PropertyBean.secureUrls = new HashSet<String>();

		try {
			StringTokenizer tokenizer = new StringTokenizer(secureUrls.iterator().next(), "|");
			while (tokenizer.hasMoreElements()) {
				String token = tokenizer.nextToken();
				PropertyBean.secureUrls.add(token.trim());
			}
		} catch (Exception e) {

		}
	}
	
	public void setSecureUrls(String secureUrls) {
		PropertyBean.secureUrls = new HashSet<String>();

		try {
			StringTokenizer tokenizer = new StringTokenizer(secureUrls, "|");
			while (tokenizer.hasMoreElements()) {
				String token = tokenizer.nextToken();
				PropertyBean.secureUrls.add(token.trim());
			}
		} catch (Exception e) {

		}
	}
	
	public Set<String> getSecureUrls() {
		return PropertyBean.secureUrls;
	}
	
	public String getClient_log() {
		return client_log;
	}

	public void setClient_log(String clientLog) {
		client_log = clientLog;
	}
	
	public String getFileSignatures() {
		return fileSignatures;
	}

	public void setFileSignatures(String fileSignatures) {
		PropertyBean.fileSignatures = fileSignatures;
	}
	
	public int getBufferSize() {
		return bufferSize;
	}

	public void setBufferSize(int bufferSize) {
		PropertyBean.bufferSize = bufferSize;
	}
	
	public String getBucketName()
	{
		return bucketName;
	}
	
	public void setBucketName(String bucketName)
	{
		PropertyBean.bucketName = bucketName;
	}

	public String getAccessKey()
	{
		return accessKey;
	}
	
	public void setAccessKey(String accessKey)
	{
		PropertyBean.accessKey = accessKey;
	}
	
	public String getSecretKey(){
		return secretKey;
	}
	
	public void setSecretKey(String secretKey)
	{
		PropertyBean.secretKey = secretKey;
	}
	
	public String getOpenAPIServerUrl() {
		return openAPIServerUrl;
	}
	
	public void setOpenAPIServerUrl(String openAPIServerUrl) {
		PropertyBean.openAPIServerUrl = openAPIServerUrl;
	}
	public String getOpenAPIFileServerUrl() {
		return openAPIFileServerUrl;
	}
	
	public void setOpenAPIFileServerUrl(String OpenAPIFileServerUrl) {
		PropertyBean.openAPIFileServerUrl = OpenAPIFileServerUrl;
	}
	public String getCookieEncryptKey() {
		return cookieEncryptKey;
	}
	
	public void setCookieEncryptKey(String cookieEncryptKey) {
		PropertyBean.cookieEncryptKey = cookieEncryptKey;
	}
	
	public String getSuccessActionRedirectUrl()
	{
		return successActionRedirectUrl;
	}
	
	public void setSuccessActionRedirectUrl(String successActionRedirectUrl)
	{
		PropertyBean.successActionRedirectUrl = successActionRedirectUrl;
	}
	
	public int getSmsValidTime() {
		return smsValidTime;
	}

	public void setSmsValidTime(int input) {
		PropertyBean.smsValidTime = input;
	}
	
	public void setAllowedIPs(Set<String> allowedIPs) {
		PropertyBean.allowedIPs = new HashSet<String>();

		try {
			StringTokenizer tokenizer = new StringTokenizer(allowedIPs.iterator().next(), "|");
			while (tokenizer.hasMoreElements()) {
				String token = tokenizer.nextToken();
				PropertyBean.allowedIPs.add(token.trim());
			}
		} catch (Exception e) {

		}
	}

	public void setAllowedIPs(String allowedIPs) {
		PropertyBean.allowedIPs = new HashSet<String>();

		try {
			StringTokenizer tokenizer = new StringTokenizer(allowedIPs, "|");
			while (tokenizer.hasMoreElements()) {
				String token = tokenizer.nextToken();
				PropertyBean.allowedIPs.add(token.trim());
			}
		} catch (Exception e) {

		}
	}
	
	public Set<String> getAllowedIPs() {
		return PropertyBean.allowedIPs;
	}

	public String getLicenseServer() {
		return licenseServer;
	}

	public void setLicenseServer(String licenseServer) {
		PropertyBean.licenseServer = licenseServer;
	}

	public int getInternalConnctionTimeout() {
		return internalConnectionTimeout;
	}
	
	public void setInternalConnectionTimeout(int internalConnectionTimeout) {
		PropertyBean.internalConnectionTimeout = internalConnectionTimeout;
	}
	
	public String getSecuredDBUsername() {
		return securedDBUsername;
	}

	public void setSecuredDBUsername(String securedDBUsername) {
		PropertyBean.securedDBUsername = securedDBUsername;
	}

	public String getSecuredDBPassword() {
		return securedDBPassword;
	}
	
	public void setSecuredDBPassword(String securedDBPassword) {
		PropertyBean.securedDBPassword = securedDBPassword;
	}
	
	public String getSmsAuthServerUrl() {
		return smsAuthServerUrl;
	}

	public void setSmsAuthServerUrl(String smsAuthServerUrl) {
		PropertyBean.smsAuthServerUrl = smsAuthServerUrl;
	}
	
	/**
	 * @param ssmConnectionTimeout the ssmConnectionTimeout to set
	 */
	public void setSsmConnectionTimeout(int ssmConnectionTimeout) {
		PropertyBean.ssmConnectionTimeout = ssmConnectionTimeout;
	}	
	
	/**
	 * @param ssmMsgEncryption the ssmMsgEncryption to set
	 */
	public void setSsmMsgEncryption(int ssmMsgEncryption) {
		PropertyBean.ssmMsgEncryption = ssmMsgEncryption;
	}	
	
	/**
	 * @param sppNoti the sppNoti to set
	 */
	public void setSppNoti(int sppNoti) {
		PropertyBean.sppNoti = sppNoti;
	}	
	
	/**
	 * @param sppThreadpoolsize the sppThreadpoolsize to set
	 */
	public void setSppThreadpoolsize(int sppThreadpoolsize) {
		PropertyBean.sppThreadpoolsize = sppThreadpoolsize;
	}
	
	/**
	 * @param pushClosetime the pushClosetime to set
	 */
	public void setPushClosetime(int pushClosetime) {
		PropertyBean.pushClosetime = pushClosetime;
	}
	
	/**
	 * @param pushSchedulerInterval the pushSchedulerInterval to set
	 */
	public void setPushSchedulerInterval(int pushSchedulerInterval) {
		PropertyBean.pushSchedulerInterval = pushSchedulerInterval;
	}

	/**
	 * @param pushSchedulerThreadpoolsize the pushSchedulerThreadpoolsize to set
	 */
	public void setPushSchedulerThreadpoolsize(
			int pushSchedulerThreadpoolsize) {
		PropertyBean.pushSchedulerThreadpoolsize = pushSchedulerThreadpoolsize;
	}

	/**
	 * @param pushQueueThreadpoolsize the pushQueueThreadpoolsize to set
	 */
	public void setPushQueueThreadpoolsize(int pushQueueThreadpoolsize) {
		PropertyBean.pushQueueThreadpoolsize = pushQueueThreadpoolsize;
	}

	public void setGldAddress(String gldAddress) {
		PropertyBean.gldAddress = gldAddress;
	}

	public void setGldCliversion(String gldCliversion) {
		PropertyBean.gldCliversion = gldCliversion;
	}

	public void setGldPort(int gldPort) {
		PropertyBean.gldPort = gldPort;
	}

	public void setFileSvrProtocol(String fileSvrProtocol) {
		PropertyBean.fileSvrProtocol = fileSvrProtocol;
	}
	
	public void setBuddySvrProtocol(String buddySvrProtocol) {
		PropertyBean.buddySvrProtocol = buddySvrProtocol;
	}

	public static String getGldProtocol() {
		return gldProtocol;
	}

	public static void setGldProtocol(String gldProtocol) {
		PropertyBean.gldProtocol = gldProtocol;
	}
	
	public void setRegionJp(String regionJp) {
		PropertyBean.regionJp = regionJp.split(",");
	}
	
	public void setRegionSg(String regionSg) {
		PropertyBean.regionSg = regionSg.split(",");
	}
	
	public void setRegionEu(String regionEu) {
		PropertyBean.regionEu = regionEu.split(",");
	}
	
	public void setRegionCn(String regionCn) {
		PropertyBean.regionCn = regionCn.split(",");
	}
	
	public void setRegionKr(String regionKr) {
		PropertyBean.regionKr = regionKr.split(",");
	}
	
	public void setRegionDev(String regionDev) {
		PropertyBean.regionDev = regionDev.split(",");
	}
	
	public void setRegionStg(String regionStg) {
		PropertyBean.regionStg = regionStg.split(",");
	}
	
	/**
	 * @return the file_url_mapping
	 */
	public String[] getFile_url_mapping() {
		return file_url_mapping;
	}
	/**
	 * @param file_url_mapping the file_url_mapping to set
	 */
	public void setFile_url_mapping(String[] file_url_mapping) {
		PropertyBean.file_url_mapping = file_url_mapping;
	}

	/**
	 * @param fileSvrAddr the fileSvrAddr to set
	 */
	public void setFileSvrAddr(String fileSvrAddr) {
		PropertyBean.fileSvrAddr = fileSvrAddr;
	}

	/**
	 * @param buddySvrAddr the buddySvrAddr to set
	 */
	public void setBuddySvrAddr(String buddySvrAddr) {
		PropertyBean.buddySvrAddr = buddySvrAddr;
	}

	public void setApiAccountHost(String apiAccountHost) {
		PropertyBean.apiAccountHost = apiAccountHost;
	}

	public void setServerType(String serverType) {
		PropertyBean.serverType = serverType;
	}

	public void setHttpConnectionTimeout(int httpConnectionTimeout) {
		PropertyBean.httpConnectionTimeout = httpConnectionTimeout;
	}

	public void setHttpSotimeout(int httpSotimeout) {
		PropertyBean.httpSotimeout = httpSotimeout;
	}
	
	public void setDecryptMode(String decryptMode) {
		PropertyBean.decryptMode = decryptMode;
	}

	public void setEncryptMode(String encryptMode) {
		PropertyBean.encryptMode = encryptMode;
	}	

	public String getElbinfoMsgPriElbAddr() {
		return elbinfoMsgPriElbAddr;
	}

	public void setElbinfoMsgPriElbAddr(String elbinfoMsgPriElbAddr) {
		PropertyBean.elbinfoMsgPriElbAddr = elbinfoMsgPriElbAddr;
	}

	public int getElbinfoMsgPriPort() {
		return elbinfoMsgPriPort;
	}

	public void setElbinfoMsgPriPort(int elbinfoMsgPriPort) {
		PropertyBean.elbinfoMsgPriPort = elbinfoMsgPriPort;
	}

	public String getElbinfoMsgSecElbAddr() {
		return elbinfoMsgSecElbAddr;
	}

	public void setElbinfoMsgSecElbAddr(String elbinfoMsgSecElbAddr) {
		PropertyBean.elbinfoMsgSecElbAddr = elbinfoMsgSecElbAddr;
	}

	public int getElbinfoMsgSecPort() {
		return elbinfoMsgSecPort;
	}

	public void setElbinfoMsgSecPort(int elbinfoMsgSecPort) {
		PropertyBean.elbinfoMsgSecPort = elbinfoMsgSecPort;
	}

}
